package fileIO;

import java.io.IOException;

import javax.swing.JOptionPane;


import org.jdom.*;
import org.jdom.input.SAXBuilder;

public class XMLParser {

	/**
	 * Parses an XML document and returns root node
	 * @param filePath
	 * @return
	 */
	public static Element parseDocument(String filePath){
		
		SAXBuilder builder = new SAXBuilder();
		
		try {
			Document doc = builder.build(filePath);
			Element root = doc.getRootElement();
			return root;
		} catch (JDOMException e) {
			e.printStackTrace();
			return null;
		} catch (IOException e) {
		//	JOptionPane.showMessageDialog(null, "Could not locate file at: " + filePath);
			e.printStackTrace();
			return null;
		} catch(Exception e){
			return null;
		}
	}
}
